package com.erainm.sort;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * Created by erainm on 2021/08/14/5:43 下午.
 *
 * @Description: reducer，处理排序
 */
public class SortReducer extends Reducer<IntWritable,IntWritable,IntWritable,IntWritable> {
    IntWritable rank = new IntWritable(1); //存放名次

    @Override
    protected void reduce(IntWritable key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        for (IntWritable item : values) {
            context.write(rank,key);
            rank = new IntWritable(rank.get() + 1);
        }
    }
}
